package com.example.gausspaper.service;

import com.example.gausspaper.domain.User;
import com.example.gausspaper.repository.UserRepository;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class LoginService {
    @Autowired
    private UserRepository userRepository;

    public boolean register(User newuser){
        //System.out.println(newuser.getUserId()+newuser.getName()+newuser.getPassword()+newuser.getRoleName());
        userRepository.save(newuser);
        //userRepository.register(newuser.getUserId(),newuser.getPassword(),newuser.getName(),newuser.getRoleName());
        return true;
    }

    /*public boolean checkIn(String id, String password){
        String rightpw = userRepository.checkIn(id);
        //System.out.println(rightpw);
        if(rightpw != null && rightpw.equals(password))
            return true;
        else
            return false;
    }

    public int checkRole(String id){
        String role = userRepository.checkRole(id);
        if (role.equals("超级管理"))
            return 0;
        else return 1; //普通用户
    }*/
}
